package seismosurfer.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JToolBar;

import com.bbn.openmap.LightMapHandlerChild;

/**
 * A toolbar where the time slider component and its associated
 * buttons are placed.
 *
 */
public class TimeSliderToolBar extends JToolBar implements ActionListener,
        LightMapHandlerChild {
    
    private static final long serialVersionUID = 4231754972376655736L;

    protected seismosurfer.gui.TimeSlider theSlider;

    protected JButton deactivateBtn;

    protected ConfigureButton confBtn;

    protected final static String deactivateCmd = "cancel";

    public TimeSliderToolBar() {
        super();
        setVisible(false);

        theSlider = new TimeSlider();
        add(theSlider);

        confBtn = new ConfigureButton(theSlider);
        add(confBtn);

        deactivateBtn = new JButton("Deactivate");
        deactivateBtn.addActionListener(this);
        deactivateBtn.setActionCommand(deactivateCmd);
        add(deactivateBtn);
    }

    public TimeSlider getTimeSlider() {
        return theSlider;
    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getActionCommand() == deactivateCmd) {
            setVisible(false);
        }
    }

    public void findAndInit(Object someObj) {
        theSlider.findAndInit(someObj);
        confBtn.findAndInit(someObj);
    }

    public void findAndUndo(Object someObj) {
        theSlider.findAndUndo(someObj);
        confBtn.findAndUndo(someObj);
    }
}
